//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#include "../Variable.h"

using namespace Native::Compiling;
using namespace Native::Compiling::Sql;

CVariable::CVariable() :
    _output(false)
{
}

CVariable::CVariable(C_VARIABLE& that) :
    CField(that),
    _name(that._name),
    _type(that._type),
    _value(that._value),
    _output(that._output)
{
}

CVariable::CVariable(C_VARIABLE&& that) :
    CField(that),
    _name(that._name),
    _type(that._type),
    _value(that._value),
    _output(that._output)
{
}

CVariable::~CVariable()
{
}

wstring CVariable::ToString() const
{
    wchar_t cstring[128] = {0};
    wstring string(CField::ToString());

    wsprintf(
        cstring,
        L"Name:[%s], Type:[%s], Value:[%s], Output:[%s]",
        _name.ToCString(),
        _type.ToCString(),
        _value.ToCString(),
        _output.ToString().c_str());

    string.append(L",");
    string.append(cstring);

    return move(string);
}

bool CVariable::operator==(C_VARIABLE& rvalue) const
{
    return
        CField::operator==(rvalue) &&
        _name == rvalue._name &&
        _type == rvalue._type&&
        _value == rvalue._value &&
        _output == rvalue._output;
}

bool CVariable::operator!=(C_VARIABLE& rvalue) const
{
    return !operator==(rvalue);
}

void CVariable::Clear()
{
    CField::Clear();

    _name = EMPTY_STRING;
    _type = EMPTY_STRING;
    _value = EMPTY_STRING;
}

CString CVariable::ToCode() const
{
    return EMPTY_STRING;
}

C_VARIABLE& CVariable::operator=(C_VARIABLE& rvalue)
{
    CField::operator=(rvalue);

    _name = rvalue._name;
    _type = rvalue._type;
    _value = rvalue._value;
    _output = rvalue._output;

    return *this;
}
